package engine

import "log"

type Scheduler interface {
	Submit(request ...Request)
}

type ConcurrentEngine struct {
	WorkerCount int
	Scheduler   Scheduler
}

func (e *ConcurrentEngine) Run(seeds ...Request) {
	for _, r := range seeds {
		e.Scheduler.Submit(r)
	}
	in := make(chan Request)
	out := make(chan ParserResult)
	for i := 0; i < e.WorkerCount; i++ {
		createWorker(in, out)
	}
	for {
		result := <-out
		for _, item := range result.Items {
			log.Printf("Got item %v\n", item)
		}
		e.Scheduler.Submit(result.Requests...)

	}
}
func createWorker(in chan Request, out chan ParserResult) {
	go func() {
		req := <-in

	}()
}
